/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Alexandre
 */
@Entity
@Table(name = "recepit")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Recepit.findAll", query = "SELECT r FROM Recepit r"),
    @NamedQuery(name = "Recepit.findByIdrecepit", query = "SELECT r FROM Recepit r WHERE r.idrecepit = :idrecepit"),
    @NamedQuery(name = "Recepit.findByConcept", query = "SELECT r FROM Recepit r WHERE r.concept = :concept"),
    @NamedQuery(name = "Recepit.findByCategoryId", query = "SELECT r FROM Recepit r WHERE r.categoryId = :categoryId"),
    @NamedQuery(name = "Recepit.findByQuantity", query = "SELECT r FROM Recepit r WHERE r.quantity = :quantity"),
    @NamedQuery(name = "Recepit.findByTimestamp", query = "SELECT r FROM Recepit r WHERE r.timestamp = :timestamp"),
    @NamedQuery(name = "Recepit.findByLoop", query = "SELECT r FROM Recepit r WHERE r.loop = :loop")})
public class Recepit implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "idrecepit")
    private Integer idrecepit;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "concept")
    private String concept;
    @Basic(optional = false)
    @NotNull
    @Column(name = "category_id")
    private int categoryId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "quantity")
    private float quantity;
    @Basic(optional = false)
    @NotNull
    @Column(name = "timestamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timestamp;
    @Basic(optional = false)
    @NotNull
    @Column(name = "loop")
    private int loop;
    @JoinColumn(name = "group_id", referencedColumnName = "idgroup")
    @ManyToOne(optional = false)
    private GroupDefinition groupId;
    @JoinColumn(name = "payer", referencedColumnName = "username")
    @ManyToOne(optional = false)
    private User payer;

    public Recepit() {
    }

    public Recepit(Integer idrecepit) {
        this.idrecepit = idrecepit;
    }

    public Recepit(Integer idrecepit, String concept, int categoryId, float quantity, Date timestamp, int loop) {
        this.idrecepit = idrecepit;
        this.concept = concept;
        this.categoryId = categoryId;
        this.quantity = quantity;
        this.timestamp = timestamp;
        this.loop = loop;
    }

    public Integer getIdrecepit() {
        return idrecepit;
    }

    public void setIdrecepit(Integer idrecepit) {
        this.idrecepit = idrecepit;
    }

    public String getConcept() {
        return concept;
    }

    public void setConcept(String concept) {
        this.concept = concept;
    }

    public int getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(int categoryId) {
        this.categoryId = categoryId;
    }

    public float getQuantity() {
        return quantity;
    }

    public void setQuantity(float quantity) {
        this.quantity = quantity;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    public int getLoop() {
        return loop;
    }

    public void setLoop(int loop) {
        this.loop = loop;
    }

    public GroupDefinition getGroupId() {
        return groupId;
    }

    public void setGroupId(GroupDefinition groupId) {
        this.groupId = groupId;
    }

    public User getPayer() {
        return payer;
    }

    public void setPayer(User payer) {
        this.payer = payer;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idrecepit != null ? idrecepit.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Recepit)) {
            return false;
        }
        Recepit other = (Recepit) object;
        if ((this.idrecepit == null && other.idrecepit != null) || (this.idrecepit != null && !this.idrecepit.equals(other.idrecepit))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Recepit[ idrecepit=" + idrecepit + " ]";
    }

}
